#ifndef INTERRUPT_H
#define INTERRUPT_H

#include "sys.h"
#include <stm32f4xx.h>

#define INTERRUPT_TIM TIM6                                                                  // TIM6时钟
#define INTERRUPT_METHOD_SIZE 10                                                            // 中断数量
#define INTERRUPT_TIM_Period (2 - 1)                                                        // 自动重载
#define INTERRUPT_TIM_IRQn TIM6_DAC_IRQn                                                    // TIM6中断
#define INTERRUPT_TIM_Prescaler (45000 - 1)                                                 // 预分频值
#define INTERRUPT_NVIC_IRQChannelSubPriority 0                                              // 响应优先
#define INTERRUPT_TIM_IRQHandler TIM6_DAC_IRQHandler                                        // 中断处理
#define INTERRUPT_NVIC_IRQChannelPreemptionPriority 2                                       // 抢占优先
#define INTERRUPT_RCC_APBPeriphClockCmd RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE) // 使能时钟

/**
 * @name 中断初始化
 * @description
 * @function
 * @returns {*}
 * @requires []
 */
void interrupt_init(void);

/**
 * @name 中断注册
 * @description
 * @function
 * @param {void (*method)(void)} 中断函数
 * @returns {uint8_t} 0: 成功, 1: 注册已满, 2: 已经注册
 * @requires []
 */
uint8_t interrupt_register(void (*method)(void));

/**
 * @name 中断注销
 * @description
 * @function
 * @param {void (*method)(void)} 中断函数
 * @returns {uint8_t} 0: 成功, 1: 注销失败
 * @requires []
 */
uint8_t interrupt_unregister(void (*method)(void));
#endif
